# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=bletchley
pkgver=0.0.1
pkgrel=16
groups=('blackarch' 'blackarch-crypto')
pkgdesc='A collection of practical application cryptanalysis tools.'
arch=('x86_64' 'aarch64')
url='https://code.google.com/p/bletchley/'
license=('GPL')
depends=('python3' 'python-requests')
makedepends=('subversion' 'scons')
source=('svn+https://code.blindspotsecurity.com/dav/bletchley/trunk/')
#source=("https://googledrive.com/host/0B6HCWPzk_jKoVHI5WV9EMURfbms/bletchley-src-$pkgver.tar.gz")
sha512sums=('SKIP')

build() {
  cd trunk

  scons
}

package() {
  cd trunk

  _tools="bletchley-analyze bletchley-clonecertchain bletchley-decode"
  _tools="$_tools bletchley-encode bletchley-http2py bletchley-nextrand"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  PREFIX="$pkgdir" scons install

  install -Dm 644 INSTALL "$pkgdir/usr/share/doc/$pkgname/INSTALL"
  install -m 644 doc/TODO "$pkgdir/usr/share/doc/$pkgname/TODO"
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf build doc src bin INSTALL LICENSE SConstruct

  cp -a * "$pkgdir/usr/share/$pkgname/"

  mv "$pkgdir/bin/"* "$pkgdir/usr/share/$pkgname/lib/"
  rmdir "$pkgdir/bin"

  for t in $_tools
  do
    cat > "$pkgdir/usr/bin/$t" << EOF
#!/bin/sh
cd /usr/share/$pkgname/lib
exec python3 $t "\$@"
EOF
    chmod +x "$pkgdir/usr/bin/$t"
  done
}

